<?php
/**
 * Created by PhpStorm.
 * User: changyifan
 * Date: 2018/2/7
 * Time: 下午3:25
 * 测试规则
 */

namespace Home\Model;
use Think\Model\BaseModel;

class TestruleModel extends BaseModel{

    protected $_link = array(
        'Point' =>  array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Point',
            'foreign_key' => 'poi_id',
            'mapping_fields' => 'poi_content',
            'as_fields' => 'knowledge_content'
        ),
        'Chapter' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Chapter',
            'foreign_key' => 'cha_id',
            'mapping_fields' => 'cha_name',
            'as_fields' => 'cha_name'
        )
    );


    public function getTestRuleInfoListWithChapterrId($chapter_id){
        if ($chapter_id == 0){
            $chapter_id = array('like','%%');
        }
        $result = $this ->where(array('cha_id'=>$chapter_id))->relation(true) -> select();
        if($result){
            return $result;
        }else{
            return array();
        }

    }

}